//
//  YFStarVideoModel.m
//  SquashSpark
//
//  Created by Coollang on 2017/11/3.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFStarVideoModel.h"
#import <YYKit/YYKit.h>
#import "CoachVideo.h"
#import "NSString+Extension.h"

@implementation YFStarVideoModel

+ (NSArray <YFStarVideoModel *> *)creatModelArrayWith:(NSArray *)sourceArray{
    NSMutableArray *arry = [NSMutableArray array];
    for (NSDictionary *dic in sourceArray) {
        [arry addObject:[self creatModelWith:dic]];
    }
    
    YFStarVideoModel *model = [self new];
    model.starName = @"Coming Soon...";
    model.state = 0;
    model.videosCount = 0;
    [arry addObject:model];
    return arry.mutableCopy;
}

+ (YFStarVideoModel *)creatModelWith:(NSDictionary *)sourceDic{
    YFStarVideoModel *model = [self new];
    model.nodeID = [NSString checkIfNullWithString:sourceDic[@"ID"]];
    model.starName = [NSString checkIfNullWithString:sourceDic[@"Name"]];
    model.posterImageName = [NSString checkIfNullWithString:sourceDic[@"PicUrl"]];
    model.state = [[NSString checkIfNullWithString:sourceDic[@"State"]] boolValue];
    model.videosCount = [[NSString checkIfNullWithString:sourceDic[@"Cnt"]] integerValue];
    return model;
}

+ (NSArray *)creatTestStarVideodata {
    NSArray *testData = @[
                          @{
                              @"posterImageName":@"videosOther_0",
                              @"posterTitle":@"Mike's training",
                              @"videosCount":@(3),
                              @"starName":@"Mike",
                              },
                          @{
                              @"posterImageName":@"videosOther_1",
                              @"posterTitle":@"Michel's warm-up exercise",
                              @"videosCount":@(2),
                              @"starName":@"Michel",
                              },
                          @{
                              @"posterImageName":@"videosOther_2",
                              @"posterTitle":@"Jack's strength training",
                              @"videosCount":@(4),
                              @"starName":@"Jack",
                              }
                          ];
    
    NSArray *videoArray = [NSArray modelArrayWithClass:self json:testData];
    for (YFStarVideoModel *item in videoArray) {
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSInteger i = 0; i < item.videosCount; i++) {
            CoachVideo *video = [CoachVideo creatTestCoachVideoWithStarName:item.starName];
            [arrM addObject:video];
        }
        item.videoGroups = @{[NSString stringWithFormat:@"%@'s action video",item.starName]:arrM.copy};
    }
    return videoArray;
}

@end
